#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <stdbool.h>

int get_digit(int num)
{
	int count = 0;
	while (num)
	{
		num /= 10;
		count++;
	}
	return count;
}

bool judge_num(int num, int n)
{
	int i = 0;
	int count = 0;
	for (i = 0; i < n; i++)
	{
		int temp = (num / (int)pow(10, i)) % 10;
		count += (int)pow(temp, n);
	}
	if (count == num)
		return true;
	return false;
}
int main()
{
	int num = 0;
	int n = 0;
	
	for (num = 0; num < 100000; num++)
	{
		n = get_digit(num);
		if (judge_num(num, n))
			printf("%d ", num);
	}
	
	return 0;
}
